package com.enation.app.javashop.api.client;

import com.enation.app.javashop.mapper.system.PageDataGoodsMapper;
import com.enation.app.javashop.model.pagedata.PageData;
import com.enation.app.javashop.service.pagedata.PageDataManager;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @author fk
 * @version v2.0
 * @Description: 楼层对外client
 * @date 2018/7/30 15:06
 * @since v7.0.0
 */
@Api(description = "楼层相关API")
@RestController
@RequestMapping("/client/pages")
@Validated
@ApiIgnore
public class PageDataClientController {

    @Autowired
    private PageDataManager pageDataManager;

    @Autowired
    private PageDataGoodsMapper pageDataGoodsMapper;


    @PutMapping(value = "/{id}")
    public void edit(@RequestBody PageData page, @PathVariable("id") Long id) {
        this.pageDataManager.edit(page, id);
    }

    @GetMapping(value = "/selectPageByGoods")
    public List<PageData> selectPageByGoods(@RequestParam("goods_ids") Long[] goodsIds){
        return this.pageDataGoodsMapper.selectPageList(goodsIds);
    }

}
